
#include <utils.h>
#include <gio/gio.h>




enum  {
	UTILS_DUMMY_PROPERTY
};
static void __lambda0 (GtkButton* s);
static void ___lambda0_gtk_widget_style_set (GtkButton* _sender, GtkStyle* previous_style, gpointer self);
static GdkColor* _gdk_color_dup (GdkColor* self);
static gpointer utils_parent_class = NULL;



static void __lambda0 (GtkButton* s) {
	gint h;
	gint w;
	g_return_if_fail (s != NULL);
	h = 0;
	w = 0;
	gtk_icon_size_lookup_for_settings (gtk_widget_get_settings ((GtkWidget*) s), GTK_ICON_SIZE_MENU, &w, &h);
	gtk_widget_set_size_request ((GtkWidget*) s, w + 2, h + 2);
}


static void ___lambda0_gtk_widget_style_set (GtkButton* _sender, GtkStyle* previous_style, gpointer self) {
	__lambda0 (_sender);
}


/* Z pliku "utils.vala" będącego częścią kodu źródłowego Val(a)ide, opublikowanego na licencji GPL */
GtkButton* utils_create_small_button (GtkImage* image) {
	GtkButton* button;
	GtkRcStyle* rcstyle;
	GtkButton* _tmp0;
	g_return_val_if_fail (image != NULL, NULL);
	button = g_object_ref_sink ((GtkButton*) gtk_button_new ());
	gtk_button_set_relief (button, GTK_RELIEF_NONE);
	/* don't allow focus on the close button */
	gtk_button_set_focus_on_click (button, FALSE);
	/* make it as small as possible */
	rcstyle = gtk_rc_style_new ();
	rcstyle->xthickness = rcstyle->ythickness = 0;
	gtk_widget_modify_style ((GtkWidget*) button, rcstyle);
	gtk_widget_show ((GtkWidget*) image);
	gtk_container_add ((GtkContainer*) button, (GtkWidget*) image);
	g_signal_connect ((GtkWidget*) button, "style-set", (GCallback) ___lambda0_gtk_widget_style_set, NULL);
	_tmp0 = NULL;
	return (_tmp0 = button, (rcstyle == NULL) ? NULL : (rcstyle = (g_object_unref (rcstyle), NULL)), _tmp0);
}


char* utils_get_mime_type (const char* filename, GError** error) {
	GError * inner_error;
	GFile* file;
	GFileInfo* file_info;
	const char* _tmp0;
	char* _tmp1;
	g_return_val_if_fail (filename != NULL, NULL);
	inner_error = NULL;
	file = g_file_new_for_path (filename);
	file_info = g_file_query_info (file, "standard::*", G_FILE_QUERY_INFO_NONE, NULL, &inner_error);
	if (inner_error != NULL) {
		g_propagate_error (error, inner_error);
		(file == NULL) ? NULL : (file = (g_object_unref (file), NULL));
		return NULL;
	}
	_tmp0 = NULL;
	_tmp1 = NULL;
	return (_tmp1 = (_tmp0 = g_content_type_get_mime_type (g_file_info_get_content_type (file_info)), (_tmp0 == NULL) ? NULL : g_strdup (_tmp0)), (file == NULL) ? NULL : (file = (g_object_unref (file), NULL)), (file_info == NULL) ? NULL : (file_info = (g_object_unref (file_info), NULL)), _tmp1);
}


static GdkColor* _gdk_color_dup (GdkColor* self) {
	GdkColor* dup;
	dup = g_new0 (GdkColor, 1);
	memcpy (dup, self, sizeof (GdkColor));
	return dup;
}


void utils_set_widget_warrnig_background (GtkWidget** widget) {
	GdkColor* c = {0};
	GdkColor* _tmp3 = {0};
	GdkColor* _tmp2 = {0};
	gboolean _tmp1;
	GdkColor _tmp0 = {0};
	g_return_if_fail (widget != NULL);
	_tmp1 = gdk_color_parse ("#D13F3F", &_tmp0);
	c = (_tmp2 = (_tmp3 = &_tmp0, (_tmp3 == NULL) ? NULL : _gdk_color_dup (_tmp3)), (c == NULL) ? NULL : (c = (g_free (c), NULL)), _tmp2);
	_tmp1;
	gtk_widget_modify_base ((*widget), GTK_STATE_NORMAL, c);
	(c == NULL) ? NULL : (c = (g_free (c), NULL));
}


void utils_neg_color (GdkColor* c) {
	(*c).red = ~(*c).red;
	(*c).green = ~(*c).green;
	(*c).blue = ~(*c).blue;
}


Utils* utils_construct (GType object_type) {
	Utils * self;
	self = g_object_newv (object_type, 0, NULL);
	return self;
}


Utils* utils_new (void) {
	return utils_construct (TYPE_UTILS);
}


static void utils_class_init (UtilsClass * klass) {
	utils_parent_class = g_type_class_peek_parent (klass);
}


static void utils_instance_init (Utils * self) {
}


GType utils_get_type (void) {
	static GType utils_type_id = 0;
	if (utils_type_id == 0) {
		static const GTypeInfo g_define_type_info = { sizeof (UtilsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) utils_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Utils), 0, (GInstanceInitFunc) utils_instance_init, NULL };
		utils_type_id = g_type_register_static (G_TYPE_OBJECT, "Utils", &g_define_type_info, 0);
	}
	return utils_type_id;
}




